package framework.common;

import java.util.LinkedList;
import java.util.List;

/**
 * センサ要求を束ねたデバイス要求<br/>
 *
 * @author uehara
 */
public class DeviceRequest extends DeviceMessage {

	private Client client;

	/**
	 * セッションIDとしてclientを用いる。
	 *
	 * @param client
	 */
	public DeviceRequest(Client client) {
		this.client = client;
	}

	public void add(SensorRequest req) {
		getMessages().add(req);
	}

	public List<SensorRequest> getRequests() {
		List<SensorRequest> requests = new LinkedList<SensorRequest>();
		for (SensorMessage m : getMessages()) {
			if (m instanceof SensorRequest) {
				requests.add((SensorRequest) m);
			}
		}
		return requests;
	}

	public void setRequests(List<SensorRequest> requests) {
		for (SensorRequest req : requests) {
			getMessages().add(req);
		}
	}

	public Client getClient() {
		return client;
	}

}
